use std::collections::HashMap;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use rumqttd::{Config, ServerSettings, Broker, ConnectionSettings};

pub(crate) fn create_mqtt(){
    let mut broker = Broker::new(build_config());
    broker.start().unwrap();
    
}


pub(crate) fn build_config() -> Config{
    let mut v5_hash:HashMap<String, ServerSettings> = HashMap::new();
    let  socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 1883);
    let  connections = ConnectionSettings{
        connection_timeout_ms:30,
        max_payload_size: 1048576,
        max_inflight_count:20,
        auth: None,
        external_auth:None,
        dynamic_filters:false
    };
    v5_hash.insert("v5.1".to_string(), ServerSettings{
        name:"v5-1".to_string(),
        listen: socket,
        tls:None,
        next_connection_delay_ms: 5000,
        connections
    });

    let config = Config{
        id: 11011,
        v5:Some(v5_hash),
        ..Default::default()
    };

    config
}

